package net.csdn.business.common.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.csdn.business.common.constant.CommonConstants;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author wanghang
 * @version 1.0
 * @date 2022/8/24 11:37
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class EventDataRepoCommitVo implements Serializable {

    private Integer action;
    private String actionName;

    @JsonProperty(value = "object_kind")
    @SerializedName(value = ":object_kind")
    private String objectKind;

    @JsonProperty(value = "created_at")
    private String createdAt;

    private EventProjectVo project;

    @JsonProperty(value = "commits")
    @SerializedName(value = ":commits")
    private List<Commit> commits;
    @JsonProperty(value = "commit_times")
    private int commitTimes;

    @Data
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class Commit {

        @JsonProperty(value = "timestamp")
        @SerializedName(value = ":timestamp")
        @JsonFormat(pattern = CommonConstants.DEFAULT_PATTERN, timezone = CommonConstants.DEFAULT_TIMEZONE)
        private Date timestamp;

        @JsonProperty(value = "message")
        @SerializedName(value = ":message")
        private String message;

        @JsonProperty(value = "author")
        @SerializedName(value = ":author")
        private Author author;

        @JsonProperty(value = "id")
        @SerializedName(value = ":id")
        private String id;

        @JsonProperty(value = "url")
        @SerializedName(value = ":url")
        private String url;
    }

    @Data
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class Author {

        @JsonProperty(value = "name")
        @SerializedName(value = ":name")
        private String name;

    }

}